<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
    <meta charset="UTF-8">
    <title>用户列表</title>
    <script type="application/javascript" th:src="@{/layui/layui.js}"></script>
    <script type="application/javascript" th:src="@{/js/jquery-3.6.0.js}"></script>
    <script type="application/javascript" th:src="@{/js/user.js}"></script>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}"/>
    <link rel="stylesheet" th:href="@{/css/header.css}">
</head>
<body>

<div class="layui-layout layui-layout-admin">

    <div th:replace="~{commons/commons.html::header}"></div>


    <div th:replace="~{commons/commons.html::sider}"></div>


    <div class="layui-body">
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <div class="layui-tab-content" style="height: 770px;padding: 0px;margin: 10px;" >
                <div class="layui-row">
                    <div class="layui-col-md2">
                        <ul class="layui-tab-title">
                            <li id="allUserBtn" onclick="loadUserList(0,'allUser')" class="layui-this">用户列表</li>
                            <li id="managerBtn" onclick="loadUserList(2,'manager')">经理列表</li>
                            <li id="employeeBtn" onclick="loadUserList(3,'employee')">员工列表</li>
                        </ul>
                    </div>
                    <div class="layui-col-md2 layui-col-md-offset4">
                        <input id="scText" type="text" placeholder="请输入" class="layui-input" >
                    </div>
                    <div class="layui-col-md2">
                        <button id="scBtn" class="layui-btn" style="display: inline-block" onclick="fuzzyUser()">查询</button>
                    </div>
                    <div class="layui-col-md2">
                        <button class="layui-btn layui-btn-normal" id="addUser" onclick="addUser()">添加用户</button>
                    </div>

                </div>
                <div class="layui-tab-item layui-show">
                    <div id="allUser" th:fragment="allUser">
                        <table class="layui-table">
                            <thead>
                            <tr>
                                <th>用户编号</th>
                                <th>用户名</th>
                                <th>性别</th>
                                <th>电话号码</th>
                                <th>地址</th>
                                <th>角色</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr th:each="user:${userList}">
                                <td th:text="${user.getUserCode()}"></td>
                                <td th:text="${user.getUserName()}"></td>
                                <td th:text="${user.getGender()==1?'女' : '男'}"></td>
                                <td th:text="${user.getPhone()}"></td>
                                <td th:text="${user.getAddress()}"></td>
                                <td th:text="${user.getUserRoleName()}"></td>
                                <td>
                                    <a class="layui-btn" th:onclick="'javascript:userDetails(\''+${user.getId()}+'\');'">查看</a>
                                    <a class="layui-btn layui-btn-warm" th:onclick="'javascript:userUpdate(\''+${user.getId()}+'\');'">修改</a>
                                    <a class="layui-btn layui-btn-danger" th:onclick="'javascript:deleteUser(\''+${user.getId()}+'\');'">删除</a>
                                    <a class="layui-btn layui-btn-normal" th:onclick="'javascript:resetPassword(\''+${user.getId()}+'\');'" sec:authorize="hasRole('ROLE_ADMIN')">重置密码</a>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="layui-tab-item">
                    <div id="manager" th:fragment="manager">
                        <table class="layui-table">
                            <thead>
                            <tr>
                                <th>用户编号</th>
                                <th>用户名</th>
                                <th>性别</th>
                                <th>电话号码</th>
                                <th>地址</th>
                                <th>角色</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                                <tr th:each="user:${userList}">
                                    <td th:text="${user.getUserCode()}"></td>
                                    <td th:text="${user.getUserName()}"></td>
                                    <td th:text="${user.getGender()==1?'女' : '男'}"></td>
                                    <td th:text="${user.getPhone()}"></td>
                                    <td th:text="${user.getAddress()}"></td>
                                    <td th:text="${user.getUserRoleName()}"></td>
                                    <td>
                                        <a class="layui-btn" th:onclick="'javascript:userDetails(\''+${user.getId()}+'\');'">查看</a>
                                        <a class="layui-btn layui-btn-warm" th:onclick="'javascript:userUpdate(\''+${user.getId()}+'\');'">修改</a>
                                        <a class="layui-btn layui-btn-danger" th:onclick="'javascript:deleteUser(\''+${user.getId()}+'\');'">删除</a>
                                        <a class="layui-btn layui-btn-normal" th:onclick="'javascript:resetPassword(\''+${user.getId()}+'\');'" sec:authorize="hasRole('ROLE_ADMIN')">重置密码</a>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="layui-tab-item">
                    <div id="employee" th:fragment="employee">
                        <table class="layui-table">
                            <thead>
                            <tr>
                                <th>用户编号</th>
                                <th>用户名</th>
                                <th>性别</th>
                                <th>电话号码</th>
                                <th>地址</th>
                                <th>角色</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                                <tr th:each="user:${userList}">
                                    <td th:text="${user.getUserCode()}"></td>
                                    <td th:text="${user.getUserName()}"></td>
                                    <td th:text="${user.getGender()==1?'女' : '男'}"></td>
                                    <td th:text="${user.getPhone()}"></td>
                                    <td th:text="${user.getAddress()}"></td>
                                    <td th:text="${user.getUserRoleName()}"></td>
                                    <td>
                                        <a class="layui-btn" th:onclick="'javascript:userDetails(\''+${user.getId()}+'\');'">查看</a>
                                        <a class="layui-btn layui-btn-warm" th:onclick="'javascript:userUpdate(\''+${user.getId()}+'\');'">修改</a>
                                        <a class="layui-btn layui-btn-danger" th:onclick="'javascript:deleteUser(\''+${user.getId()}+'\');'">删除</a>
                                        <a class="layui-btn layui-btn-normal" th:onclick="'javascript:resetPassword(\''+${user.getId()}+'\');'" sec:authorize="hasRole('ROLE_ADMIN')">重置密码</a>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="layui-tab-item">5</div>
                <div class="layui-tab-item">6</div>
            </div>
        </div>
    </div>

<!--    <div th:replace="~{commons/commons.html::footer}"></div>-->

</div>

</body>
</html>